package org.tp8.sampleapp.jms.listener;

import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Component;
import org.tp8.sampleapp.util.SampleAppLogger;

/**
 * The listener interface for receiving sampleMessage events. The class that is
 * interested in processing a sampleMessage event implements this interface, and
 * the object created with that class is registered with a component using the
 * component's <code>addSampleMessageListener<code> method. When
 * the sampleMessage event occurs, that object's appropriate
 * method is invoked.
 * 
 * @see SampleMessageEvent
 */
@Component("sampleMessageListener")
public class SampleMessageListener implements MessageListener {

	/**
	 * The Constant log.
	 */
	private final static SampleAppLogger log = new SampleAppLogger(
			SampleMessageListener.class);

	/* (non-Javadoc)
	 * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
	 */
	@Override
	public void onMessage(Message arg0) {
		log.info("Received message: " + arg0);
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			log.error(e);
		}
		log.info("Exiting: " + arg0);
	}

}
